<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html>
		
<html>
	<head>
		<meta charset="UTF-8">
		<title>添加宣传任务</title>
		<!-- 导入jquery核心类库 -->
		<script type="text/javascript" src="../../js/jquery-1.8.3.js"></script>
		<!-- 导入easyui类库 -->
		<link rel="stylesheet" type="text/css" href="../../js/easyui/themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="../../js/easyui/themes/icon.css">
		<link rel="stylesheet" type="text/css" href="../../css/default.css">
		<script type="text/javascript" src="../../js/easyui/jquery.easyui.min.js"></script>
		<script src="../../js/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
		<!--导入在线html编辑器-->
		<script type="text/javascript" src="../../editor/kindeditor.js" ></script>
		<script type="text/javascript" src="../../editor/lang/zh_CN.js" ></script>
		<link rel="stylesheet" href="../../editor/themes/default/default.css" />

		<script type="text/javascript">
			$(function(){
				var promotion=JSON.parse(localStorage.getItem("key"));
//					$("#titleImgid").html("<img src='"+promotion.titleImg+"' alt='' width='50' height='30' />");

			if(promotion!=null){
					//回显数据
//					alert(promotion.titleImg)//http://localhost:8080/bos_management/upload/26691b6b-47a7-4e28-ae4d-fd7d7f8a1778.jpg
//					alert(promotion.description);
//					$(".ke-content").html("<img src='/bos_management/upload/57ac6ca5-62d9-4de0-92ec-bfe810c4d47e.jpg' alt='' />");
//					$("#description").html("<img src='"+promotion.titleImg+"' alt='' width='50' height='30' />")

					

//					$.post("../../promotion_find.action",{"id":promotion.id},function(data) {
						var startDate=promotion.startDate;
						startDate=startDate.substring(0,10);
						var endDate=promotion.endDate;
						endDate=endDate.substring(0,10);
						$("#id").val(promotion.id);
						$("#title").val(promotion.title);
						$("#activeScope").val(promotion.activeScope);
						$("#titleImgid").html("<img src='"+promotion.titleImg+"' alt='' width='50' height='30' />");
						$('#startDate').datebox('setValue',startDate);
						$('#endDate').datebox('setValue',endDate);
						
						$("#description").html(promotion.description);
						
						
						
//$(".ke-content", document.frames("iframename").document).html("<img src='/bos_management/upload/57ac6ca5-62d9-4de0-92ec-bfe810c4d47e.jpg' alt='' />"); 

//					});
					
					
				}
				
				$("body").css({visibility:"visible"});
				$("#back").click(function(){
					location.href = "promotion.html";
				});
				//上传图片，图片空间
				KindEditor.ready(function(K){
					window.editor=K.create("#description",{
						allowFileManager:true,
						uploadJson:"../../image_upload.action",
						fileManagerJson:"../../image_manage.action",
					});
				})
				
				//点击提交按钮，提交表单
				$("#save").click(function(){
					
					//判断表单是否合乎规范
					if($("#promotionForm").form("validate")){
						window.editor.sync();
						$("#promotionForm").submit();
					}else{
						$.messager.alert('警告','请将信息填写完整','warning');
					}
				});
			});
		</script>
	</head>
	<body class="easyui-layout" style="visibility:hidden;">
		<div region="north" style="height:31px;overflow:hidden;" split="false" border="false">
			<div class="datagrid-toolbar">
				<a id="save" icon="icon-save" href="#" class="easyui-linkbutton" plain="true">保存</a>
				<a id="back" icon="icon-back" href="#" class="easyui-linkbutton" plain="true">返回列表</a>
			</div>
		</div>
		<div region="center" style="overflow:auto;padding:5px;" border="false">
			<form id="promotionForm" method="post" action="../../promotion_save.action" enctype="multipart/form-data">
				<table class="table-edit" width="95%" align="center">
					<tr class="title">
						<td colspan="4">宣传任务
						<input type="hidden"  name="id" id="id" />
						</td><!---->
					</tr>
					<tr>
						<td>宣传概要(标题):</td>
						<td colspan="3">
							<input type="text" name="title" id="title" class="easyui-validatebox" required="true" />
						</td>
					</tr>
					<tr>
						<td>活动范围:</td>
						<td>
							<input type="text" name="activeScope" id="activeScope" class="easyui-validatebox" />
						</td>
						<td>宣传图片:</td>
						<td >
							<span id="titleImgid"></span>
							<input type="file" name="titleImgFile" id="titleImg" class="easyui-validatebox" />
							<font color="red"><s:actionmessage/></font>
						</td>
					</tr>
					<tr>
						<td>发布时间: </td>
						<td>
							<input type="text" name="startDate" id="startDate" class="easyui-datebox" required="true" />
						</td>
						<td>失效时间: </td>
						<td>
							<input type="text" name="endDate" id="endDate" class="easyui-datebox" required="true" />
						</td>
					</tr>
					<tr>
						<td>宣传内容(活动描述信息):</td>
						<td colspan="3">
							<textarea id="description" name="description" style="width:80%" rows="20"></textarea>
						</td>
					</tr>
				</table>
			</form>
		</div>
	</body>
</html>
